package cate.common.table.farm.forbidden.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cp.solution.util.str.Str;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ForbiddenRoomRow extends ERow {

    /** 类型 */
    public int roomId;
    /** 名称 */
    public String name;
    /** 周几开启 */
    public String openDayStr;
    /** 水族攻击改变 */
    public String coeffC1;
    /** 火族攻击改变 */
    public String coeffC2;
    /** 木族攻击改变 */
    public String coeffC3;
    /** 土族攻击改变 */
    public String coeffC4;
    /** 暗族攻击改变 */
    public String coeffC6;
    /** 光族攻击改变 */
    public String coeffC5;


    /** BOSS方案 */
    public String bossPlanStr;


    @Override
    public void parse(XSSFRowWrap xr) {
        this.id = xr.getInteger("类型", 0);
        this.roomId = xr.getInteger("类型", 0);
        this.name = xr.getString("名称");
        this.openDayStr = xr.getString("周几开启", "");
        this.coeffC1 = xr.getString("水族攻击改变", "");
        this.coeffC2 = xr.getString("火族攻击改变", "");
        this.coeffC3 = xr.getString("木族攻击改变", "");
        this.coeffC4 = xr.getString("土族攻击改变", "");
        this.coeffC6 = xr.getString("暗族攻击改变", "");
        this.coeffC5 = xr.getString("光族攻击改变", "");
        this.bossPlanStr = xr.getString("BOSS方案");
    }

    /** 周几和周几和周几开启啊 */
    public List<Integer> openDays = new ArrayList<>();
    /** 周几或周几需要刷新boss方案啊 */
    public List<Integer> freshDays = new ArrayList<>();
    /** BOSS方案 */
    public int[] bossPlans;

    public List<String> campAttrs = new ArrayList<>();

    @Override
    public void decode() {
        List<String> list = Arrays.asList(openDayStr.split("#"));
        list.stream().forEach(day->openDays.add(Integer.parseInt(day)));

//        openDays.add(6);
//        openDays.add(7);
        freshDays.add(7);

        if (!StringUtils.isBlank(bossPlanStr)) {
            bossPlans = Str.strArr2intArr(bossPlanStr.split("#"));
        } else {
            bossPlans = new int[1];
            bossPlans[0] = 11;
        }

        campAttrs.add(coeffC1);
        campAttrs.add(coeffC2);
        campAttrs.add(coeffC3);
        campAttrs.add(coeffC4);
        campAttrs.add(coeffC5);
        campAttrs.add(coeffC6);
    }
}
